****************************************
**PAPER: religion and voting behaviour**
**AUTHOR: Piacentini, Molteni, Maraffi**
****************************************


global data //[insert path here]
global cleaned //[insert path here]
global output  //[insert path here]
global wd //[insert path here]


use "$cleaned\ITANES_cleaned", clear


************************
***MULTINOMIAL LOGIT****
************************

colorpalette  "gs1" "gs10" , ipolate(6) nograph intensity(1.1)
global r1 `r(p1)'
global r2 `r(p2)'
global r3 `r(p3)'
global r4 `r(p4)'
global r5 `r(p5)'
global r6 `r(p6)'


mlogit vote6 i.gender i.edu i.age i.tipology c.income i.Area_Geo
margins tipology, atmeans


# delimit ;
marginsplot , 	recast(connected) recastci(rarea)  ciopt(color(gs8%20)) 
								plot1opts(lc("$r1%80") mc("$r1%90") ms(O) lp(solid) lw(thick)) 
								plot2opts(lc("$r2%80") mc("$r2%90") ms(+) lp(solid) lw(thick))
								plot3opts(lc("$r3%80") mc("$r3%90") ms(X) lp(solid) lw(thick))
								plot4opts(lc("$r4%80") mc("$r4%90") ms(S) lp(solid) lw(thick))
								plot5opts(lc("$r5%80") mc("$r5%90") ms(D) lp(solid) lw(thick))
								plot6opts(lc("$r6%80") mc("$r6%90") ms(T) lp(solid) lw(thick))
								ylabel(,grid) 
								xlabel(1 `" "Practicing" "Catholic" "' 2 `" "Nominal" "Catholic" "' 3 `" "Not" "religious" "',grid ) 
								xtitle("", margin(medium)) ytitle("", margin(zero)) 
								title(" ") 
								legend(row(6) order(7 "FDI" 12 "PD" 11 "M5s"  10 "Azione+IV" 8 "Lega" 9 "FI"   ) rowgap(*4) region(col(white)) pos(9))
;

#delimit cr

graph export "$output\Figure3_R1.png", width(6000) height(4000) replace



************************
***LOGIT****************
************************

global control i.gender i.edu i.age c.income i.Area_Geo

eststo M1, title("M1"):logit voteCDX i.attendance_R $control
eststo M2, title("M2"):logit voteCDX i.attendance_R ib2.denomination_R $control
eststo M3, title("M3"):logit voteCDX i.attendance_R##ib2.denomination_R $control

*margins, dydx(denomination_R) 
*margins, dydx(attendance_R) at(denomination_R=(1)) 
*margins, dydx(attendance_R) at(denomination_R=(2)) 

esttab M1 M2 M3, eform pr2

estout 	M1 M2 M3    ///
		using "$output\Table 2.xls",  ///
		cells("b(fmt(3)) & _star") replace ///
		stats(N R2) label interaction("*") eform  


**********************************
***MEDIATION ANALYSIS************* https://www.stata.com/new-in-stata/causal-mediation-analysis/
**********************************

global control i.gender i.edu i.age c.income i.Area_Geo

eststo M1, title("M1"):logit voteCDX ib2.denomination_R $control
margins, dydx(denomination_R)
eststo M2_abortion, title("M2 - Abortion"):logit voteCDX ib2.denomination_R abortoNO $control
eststo M2_omo, title("M2 - Homosexuality"):logit voteCDX ib2.denomination_R omoNO $control
eststo M2_imm, title("M2 - Immigration"):logit voteCDX ib2.denomination_R immNO $control
eststo M3, title("M3"):logit voteCDX ib2.denomination_R abortoNO omoNO immNO $control

*margins, dydx(ib2.denomination_R abortoNO omoNO immNO)

esttab M1 M2_abortion  M2_omo M2_imm M3, eform pr2

estout 	M1 M2_abortion  M2_omo M2_imm M3   ///
		using "$output\Table 3.xls",  ///
		cells("b(fmt(3)) & _star") replace ///
		stats(N) label interaction("*") eform     



*Mediation

gen catholic=denomination_R==1
replace catholic=. if denomination_R==.

mediate (voteCDX, logit) (abortoNO, logit) (catholic)
mediate (voteCDX, logit) (omoNO, logit) (catholic)
mediate (voteCDX, logit) (immNO, logit) (catholic)



*Check: role of religion for attitudes

/*
logit abortoNO i.attendance_R if denomination_R==1, or
logit abortoNO ib2.denomination_R i.attendance_R, or

logit omoNO i.attendance_R if denomination_R==1, or
logit omoNO ib2.denomination_R i.attendance_R, or

logit immNO i.attendance_R if denomination_R==1, or
logit immNO ib2.denomination_R i.attendance_R, or
/*


